class Solution
{
public:
    int countAsterisks(string s)
    {
        bool inBar = false;
        int count = 0;
        for (char c : s)
        {
            if (c == '|')
            {
                inBar = !inBar;
            }
            else if (!inBar)
            {
                if (c == '*')
                {
                    ++count;
                }
            }
        }
        return count;
    }
};